#include "StdAfx.h"
#include "libs\include\RF603Device.h"

using namespace RFDevice;

extern "C"
{
	RFDEVICEPROXYDLL RF603Device* CALLING_CONVENTION CreateRF603Device()
	{
		return new RF603Device();
	}

	RFDEVICEPROXYDLL void CALLING_CONVENTION DisposeRF603Device(RF603Device* rf)
	{
		rf->~RF603Device();
		rf = NULL;
	}


	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EthernetGetStreamMeasure(RF603Device* rf, LPRF60xUDPPACKET packet)
	{
		return rf->EthernetGetStreamMeasure(packet);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EthernetGetNormalizedStreamMeasure(RF603Device* rf, float* OUT lpValues)
	{
		return rf->EthernetGetNormalizedStreamMeasure(lpValues);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCanSpeed(RF603Device* rf, DWORD val)
	{
		return rf->SetCanSpeed(val);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCanStdID(RF603Device* rf, DWORD val)
	{
		return rf->SetCanStdID(val);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCanExtID(RF603Device* rf, DWORD val)
	{
		return rf->SetCanExtID(val);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCanIdTypeToExt(RF603Device* rf)
	{
		return rf->SetCanIdTypeToExt();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCanIdTypeToStd(RF603Device* rf)
	{
		return rf->SetCanIdTypeToStd();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EnableCan(RF603Device* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableCan(bEnable);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetDestinationIP(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetDestinationIP(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetDestinationIP_1(RF603Device* rf, BYTE ucValue[4])
	{
		return rf->SetDestinationIP(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetGatewayIP(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetGatewayIP(dwValue);
	}
		
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetGatewayIP_1(RF603Device* rf, BYTE ucValue[4])
	{
		return rf->SetGatewayIP(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSubnetMask(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetSubnetMask(dwValue);
	}
		
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSubnetMask_1(RF603Device* rf, BYTE ucValue[4])
	{
		return rf->SetSubnetMask(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSourceIP(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetSourceIP(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSourceIP_1(RF603Device* rf, BYTE ucValue[4])
	{
		return rf->SetSourceIP(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EnableEth(RF603Device* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableEth(bEnable);
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetCanSpeed(RF603Device* rf)
	{
		return rf->EnableEth();
	}
	
	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetCanStdID(RF603Device* rf)
	{
		return rf->GetCanStdID();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetCanExtID(RF603Device* rf)
	{
		return rf->GetCanExtID();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetCanId(RF603Device* rf)
	{
		return rf->GetCanId();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetCanState(RF603Device* rf)
	{
		return rf->GetCanState();
	}

	RFDEVICEPROXYDLL BYTE* CALLING_CONVENTION RF603Device_GetDestinationIP(RF603Device* rf)
	{
		return rf->GetDestinationIP();
	}

	RFDEVICEPROXYDLL char* CALLING_CONVENTION RF603Device_GetHumanReadableDestinationIP(RF603Device* rf)
	{
		return rf->GetHumanReadableDestinationIP();
	}

	RFDEVICEPROXYDLL BYTE* CALLING_CONVENTION RF603Device_GetGatewayIP(RF603Device* rf)
	{
		return rf->GetGatewayIP();
	}

	RFDEVICEPROXYDLL char* CALLING_CONVENTION RF603Device_GetHumanReadableGatewayIP(RF603Device* rf)
	{
		return rf->GetHumanReadableGatewayIP();
	}

	RFDEVICEPROXYDLL BYTE* CALLING_CONVENTION RF603Device_GetSubnetMask(RF603Device* rf)
	{
		return rf->GetSubnetMask();
	}

	RFDEVICEPROXYDLL char* CALLING_CONVENTION RF603Device_GetHumanReadableSubnetMask(RF603Device* rf)
	{
		return rf->GetHumanReadableSubnetMask();
	}

	RFDEVICEPROXYDLL BYTE* CALLING_CONVENTION RF603Device_GetSourceIP(RF603Device* rf)
	{
		return rf->GetSourceIP();
	}

	RFDEVICEPROXYDLL char* CALLING_CONVENTION RF603Device_GetHumanReadableSourceIP(RF603Device* rf)
	{
		return rf->GetHumanReadableSourceIP();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetEthState(RF603Device* rf)
	{
		return rf->GetEthState();
	}

	//////////////////////////////////////////////////////////////////////////
	// RF60xDevice
	//////////////////////////////////////////////////////////////////////////

	void	BindNetworkAddress(BYTE ucAddress);

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetTimeouts(RF603Device* rf, 
		LPDWORD lpdwReadIntervalTimeout, LPDWORD lpdwReadTotalTimeoutMultiplier, 
		LPDWORD lpdwReadTotalTimeoutConstant, LPDWORD lpdwWriteTotalTimeoutMultiplier, 
		LPDWORD lpdwWriteTotalTimeoutConstant)
	{
		return rf->GetTimeouts(lpdwReadIntervalTimeout, lpdwReadTotalTimeoutMultiplier, lpdwReadTotalTimeoutConstant, 
			lpdwWriteTotalTimeoutMultiplier, lpdwWriteTotalTimeoutConstant);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetTimeouts(RF603Device* rf, 
		DWORD dwReadIntervalTimeout, DWORD dwReadTotalTimeoutMultiplier, 
		DWORD dwReadTotalTimeoutConstant, DWORD dwWriteTotalTimeoutMultiplier, 
		DWORD dwWriteTotalTimeoutConstant)
	{
		return rf->SetTimeouts(dwReadIntervalTimeout, dwReadTotalTimeoutMultiplier, dwReadTotalTimeoutConstant, 
			dwWriteTotalTimeoutMultiplier, dwWriteTotalTimeoutConstant);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_HelloCmd_1(RF603Device* rf, BYTE bAddress, LPRF60xHELLOANSWER lprfHelloAnswer)
	{
		return rf->HelloCmd(bAddress, lprfHelloAnswer);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_HelloCmd(RF603Device* rf)
	{
		return rf->HelloCmd();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetStreamMeasures(RF603Device* rf, 
		LPRF60xSTREAMVALUE lpusStreamValues, DWORD dwMeasuresCount, 
		LPDWORD lpdwReadedMeasuresCount, LPDWORD lpdwBrokenPacketsCount)
	{
		return rf->GetStreamMeasures(lpusStreamValues, dwMeasuresCount, lpdwReadedMeasuresCount, lpdwBrokenPacketsCount);
	}

	RFDEVICEPROXYDLL float CALLING_CONVENTION RF603Device_GetSingleMeasure(RF603Device* rf)
	{
		return rf->GetSingleMeasure();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EnableSensor(RF603Device* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableSensor(bEnable);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EnableAnalogOut(RF603Device* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableAnalogOut(bEnable);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSampleAveraging(RF603Device* rf, BYTE ucValue)
	{
		return rf->SetSampleAveraging(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAverageModeByQuantity(RF603Device* rf)
	{
		return rf->SetAverageModeByQuantity();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAverageModeByTime(RF603Device* rf)
	{
		return rf->SetAverageModeByTime();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCANModeByRequest(RF603Device* rf)
	{
		return rf->SetCANModeByRequest();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetCANModeByClk(RF603Device* rf)
	{
		return rf->SetCANModeByClk();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetLogicOutModeToRangeOverflow(RF603Device* rf)
	{
		return rf->SetLogicOutModeToRangeOverflow();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetLogicOutModeToMutualSynchronization(RF603Device* rf)
	{
		return rf->SetLogicOutModeToMutualSynchronization();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetLogicOutModeToResZeroing(RF603Device* rf)
	{
		return rf->SetLogicOutModeToResZeroing();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetLogicOutModeToLaserPower(RF603Device* rf)
	{
		return rf->SetLogicOutModeToLaserPower();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAnalogOutModeToFrameMode(RF603Device* rf)
	{
		return rf->SetAnalogOutModeToFrameMode();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAnalogOutModeToFullMode(RF603Device* rf)
	{
		return rf->SetAnalogOutModeToFullMode();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSampleModeToTime(RF603Device* rf)
	{
		return rf->SetSampleModeToTime();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSampleModeToClk(RF603Device* rf)
	{
		return rf->SetSampleModeToClk();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetNetworkAddress(RF603Device* rf, BYTE ucValue)
	{
		return rf->SetNetworkAddress(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetBaundRate(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetBaundRate(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAverageCount(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetAverageCount(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetSamplingPeriod(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetSamplingPeriod(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetAccumulationTime(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetAccumulationTime(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetBeginAnalogRange(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetBeginAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetEndAnalogRange(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetEndAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetResultDelayTime(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetResultDelayTime(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_SetZeroPointValue(RF603Device* rf, DWORD dwValue)
	{
		return rf->SetZeroPointValue(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetPowerState(RF603Device* rf)
	{
		return rf->GetPowerState();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetAnalogOut(RF603Device* rf)
	{
		return rf->GetAnalogOut();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetSampleAveraging(RF603Device* rf)
	{
		return rf->GetSampleAveraging();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_IsAverageModeByTime(RF603Device* rf)
	{
		return rf->IsAverageModeByTime();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_IsCANModeBySynch(RF603Device* rf)
	{
		return rf->IsCANModeBySynch();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF603Device_GetLogicOutMode(RF603Device* rf)
	{
		return rf->GetLogicOutMode();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_IsAnalogOutModeFull(RF603Device* rf)
	{
		return rf->IsAnalogOutModeFull();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_IsSampleModeClk(RF603Device* rf)
	{
		return rf->IsSampleModeClk();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF603Device_GetNetworkAddress(RF603Device* rf)
	{
		return rf->GetNetworkAddress();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetBaundRate(RF603Device* rf)
	{
		return rf->GetBaundRate();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetAverageCount(RF603Device* rf)
	{
		return rf->GetAverageCount();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetSamplingPeriod(RF603Device* rf)
	{
		return rf->GetSamplingPeriod();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetAccumulationTime(RF603Device* rf)
	{
		return rf->GetAccumulationTime();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetBeginAnalogRange(RF603Device* rf)
	{
		return rf->GetBeginAnalogRange();
	}	

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetEndAnalogRange(RF603Device* rf)
	{
		return rf->GetEndAnalogRange();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetResultDelayTime(RF603Device* rf)
	{
		return rf->GetResultDelayTime();
	}


	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF603Device_GetZeroPointValue(RF603Device* rf)
	{
		return rf->GetZeroPointValue();
	}

	RFDEVICEPROXYDLL LPRF60xPARAMS CALLING_CONVENTION RF603Device_GetParams(RF603Device* rf)
	{
		return rf->GetParams();
	}

	//////////////////////////////////////////////////////////////////////////
	// RFComDevice
	//////////////////////////////////////////////////////////////////////////

	RFDEVICEPROXYDLL void CALLING_CONVENTION RF603Device_BindNetworkAddress(RF603Device* rf, BYTE ucAddress)
	{
		rf->BindNetworkAddress(ucAddress);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_OpenPort(RF603Device* rf, LPCSTR lpPort_Name, DWORD dwSpeed)
	{
		return rf->OpenPort(lpPort_Name, dwSpeed);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_ClosePort(RF603Device* rf)
	{
		return rf->ClosePort();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_ReadParameter(RF603Device* rf, BYTE bAddress, WORD wParameter, DWORD* lpdwValue)
	{
		return rf->ReadParameter(bAddress, wParameter, lpdwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_WriteParameter(RF603Device* rf, BYTE bAddress, WORD wParameter, DWORD dwValue)
	{
		return rf->WriteParameter(bAddress, wParameter, dwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_ReadCustomParameter(RF603Device* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->ReadCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_WriteCustomParameter(RF603Device* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->WriteCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_FlushToFlash(RF603Device* rf, BYTE bAddress)
	{
		return rf->FlushToFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_RestoreFromFlash(RF603Device* rf, BYTE bAddress)
	{
		return rf->RestoreFromFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_LockResult(RF603Device* rf, BYTE bAddress)
	{
		return rf->LockResult(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_Measure(RF603Device* rf, BYTE bAddress, USHORT* lpusValue)
	{
		return rf->Measure(bAddress, lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_StartStream(RF603Device* rf, BYTE bAddress)
	{
		return rf->StartStream(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_StopStream(RF603Device* rf, BYTE bAddress)
	{
		return rf->StopStream(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_GetStreamMeasure(RF603Device* rf, USHORT* lpusValue)
	{
		return rf->GetStreamMeasure(lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_CustomCmd(RF603Device* rf, char * pcInData, DWORD dwInSize, char * pcOutData, DWORD * pdwOutSize)
	{
		return rf->CustomCmd(pcInData, dwInSize, pcOutData, pdwOutSize);
	}
	RFDEVICEPROXYDLL HANDLE CALLING_CONVENTION RF603Device_GetPortHandle(RF603Device* rf)
	{
		return rf->GetPortHandle();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_ValidateData(LPBYTE lpucData, const int nDataLength)
	{
		return RF603Device::ValidateData(lpucData, nDataLength);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EthernetOpenPort(RF603Device* rf)
	{
		return rf->EthernetOpenPort();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EthernetSetTimeout(RF603Device* rf, DWORD dwTimeout)
	{
		return rf->EthernetSetTimeout(dwTimeout);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF603Device_EthernetClosePort(RF603Device* rf)
	{
		return rf->EthernetClosePort();
	}
}